package com.quark.log.event;

import com.quark.model.system.log.SysLogDTO;
import com.quark.service.system.LogService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

@Slf4j
@AllArgsConstructor
public class SysLogListener {

    private final LogService logService;

    @Async
    @Order
    @EventListener(SysLogEvent.class)
    public void saveSysLog(SysLogEvent event) {
        SysLogDTO sysLog = event.getSysLog();
        logService.saveLog(sysLog);
    }

}
